package com.csu.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.csu.common.CommonResponse;
import com.csu.entity.Classes;
import com.csu.entity.User;
import com.csu.mapper.UserMapper;
import com.csu.service.ClassesService;
import com.csu.service.UserService;
import com.csu.vo.ClassStatusVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/classManagements")
public class ClassesController {
    @Autowired
    ClassesService classesService;

    /**
     *获取班级成员
     */
    @GetMapping("/{classId}")
    //@SaCheckRole("admin")
    public CommonResponse<List<User>> getClassUsers(@PathVariable int classId){
        return classesService.getClassUsers(classId);
    }

    /**
     * 删除班级
     */
    @DeleteMapping("/{classId}")
    //@SaCheckRole("admin")
    public CommonResponse<Object> deleteClass(@PathVariable int classId){
        return classesService.deleteClass(classId);
    }

    /**
     * 注册班级
     */
    @PostMapping("")
    //@SaCheckRole("admin")
    public CommonResponse<Object> postClass(@RequestParam String className){
        return classesService.postClass(className);
    }

    /**
     * 修改班级状态
     */
    @PutMapping("/{classId}")
    //@SaCheckRole("admin")
    public CommonResponse<Object> changeStatus(@PathVariable int classId, @RequestBody ClassStatusVO classStatusVO){
        return classesService.changeStatus(classId, classStatusVO.getClassStatus());
    }
}
